<?php
namespace app\crm\model;

use app\common\model\TimeModel;
use app\common\service\BaseService;

class CrmRecord extends TimeModel
{
    protected $deleteTime = 'delete_time';
    protected $insert = ['create_user_id'];

	/**
     * 获取下次跟进时间时间
     */ 
	protected function getNextTimeAttr($value)
    {
        return date('Y-m-d H:i:s',$value);
    }

    /**
     * 获取下次跟进时间时间
     */ 
	protected function getRecordTypeAttr($value)   
    {
        $recordList = BaseService::getRecordMethodList();
        return $recordList[$value] ?? '' ;
    }

    /**
     * 获取下次跟进时间时间
     */ 
	protected function setNextTimeAttr($value)
    {
        return strtotime($value);
    }

    /**
     * 获取创建者id
     */ 
	protected function setCreateUserIdAttr($value)
    {
        return session('admin.id');
    }
	
	/**
     * 创建者
     */
    public function createUser()
    {
        return $this->hasOne('\app\admin\model\SystemAdmin', 'id', 'create_user_id');
    }
}